/**
 * 预设背景配置
 * 提供多种精美的背景样式供用户选择
 */

export const backgroundPresets = [
  // 渐变系列
  {
    id: 'tech-blue',
    name: '科技蓝',
    category: 'gradient',
    style: {
      background: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)'
    },
    preview: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)'
  },
  {
    id: 'business-purple',
    name: '商务紫',
    category: 'gradient',
    style: {
      background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
    },
    preview: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
  },
  {
    id: 'vibrant-orange',
    name: '活力橙',
    category: 'gradient',
    style: {
      background: 'linear-gradient(135deg, #fa709a 0%, #fee140 100%)'
    },
    preview: 'linear-gradient(135deg, #fa709a 0%, #fee140 100%)'
  },
  {
    id: 'forest-green',
    name: '森林绿',
    category: 'gradient',
    style: {
      background: 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)'
    },
    preview: 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)'
  },
  {
    id: 'classic-gray',
    name: '经典灰',
    category: 'gradient',
    style: {
      background: 'linear-gradient(135deg, #d7d2cc 0%, #304352 100%)'
    },
    preview: 'linear-gradient(135deg, #d7d2cc 0%, #304352 100%)'
  },
  {
    id: 'sunset-red',
    name: '夕阳红',
    category: 'gradient',
    style: {
      background: 'linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%)'
    },
    preview: 'linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%)'
  },

  // 图案系列
  {
    id: 'geometric-pattern',
    name: '几何图案',
    category: 'pattern',
    style: {
      background: 'linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)',
      backgroundImage: `
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%)
      `
    },
    preview: 'linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)'
  },
  {
    id: 'circuit-board',
    name: '电路板',
    category: 'pattern',
    style: {
      background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
      backgroundImage: `url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Cpath d='M20 20c0-11.046-8.954-20-20-20v20h20z'/%3E%3C/g%3E%3C/svg%3E")`
    },
    preview: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
  },
  {
    id: 'code-background',
    name: '代码背景',
    category: 'pattern',
    style: {
      background: 'linear-gradient(135deg, #2c3e50 0%, #34495e 100%)',
      backgroundImage: `url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`
    },
    preview: 'linear-gradient(135deg, #2c3e50 0%, #34495e 100%)'
  },
  {
    id: 'grid-texture',
    name: '网格纹理',
    category: 'pattern',
    style: {
      background: 'linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)',
      backgroundImage: `url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23000000' fill-opacity='0.05'%3E%3Crect x='0' y='0' width='10' height='10'/%3E%3C/g%3E%3C/svg%3E")`
    },
    preview: 'linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)'
  },
  {
    id: 'abstract-art',
    name: '抽象艺术',
    category: 'pattern',
    style: {
      background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
      backgroundImage: `
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.1) 0%, transparent 50%)
      `
    },
    preview: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
  },

  // 纯色系列
  {
    id: 'pure-blue',
    name: '纯净蓝',
    category: 'solid',
    style: {
      background: '#409EFF'
    },
    preview: '#409EFF'
  },
  {
    id: 'pure-green',
    name: '纯净绿',
    category: 'solid',
    style: {
      background: '#67C23A'
    },
    preview: '#67C23A'
  },
  {
    id: 'pure-purple',
    name: '纯净紫',
    category: 'solid',
    style: {
      background: '#9C27B0'
    },
    preview: '#9C27B0'
  }
]

/**
 * 根据分类获取背景预设
 * @param {string} category - 分类名称
 * @returns {Array} 该分类的背景预设数组
 */
export function getPresetsByCategory(category) {
  return backgroundPresets.filter(preset => preset.category === category)
}

/**
 * 根据ID获取背景预设
 * @param {string} id - 预设ID
 * @returns {Object|null} 背景预设对象或null
 */
export function getPresetById(id) {
  return backgroundPresets.find(preset => preset.id === id) || null
}

/**
 * 获取所有分类
 * @returns {Array} 分类数组
 */
export function getCategories() {
  const categories = [...new Set(backgroundPresets.map(preset => preset.category))]
  const categoryNames = {
    gradient: '渐变',
    pattern: '图案',
    solid: '纯色'
  }
  
  return categories.map(category => ({
    id: category,
    name: categoryNames[category] || category
  }))
}

export default backgroundPresets
